package com.cgtong.android.mvp.model;

import com.cgtong.android.bean.MessageBean;
import com.cgtong.android.http.ApiManager;
import com.cgtong.android.http.callback.BaseCallBack;
import com.cgtong.android.mvp.contract.GetMessageContract;
import com.zhouyou.http.EasyHttp;
import com.zhouyou.http.callback.CallBackProxy;
import com.zhouyou.http.callback.SimpleCallBack;
import com.zhouyou.http.exception.ApiException;
import com.zhouyou.http.model.ApiResult;

import java.util.List;

/**
 * Created by Tinwai on 2017/10/24.
 */
public class GetMessageModel implements GetMessageContract.Model {
    @Override
    public void getUnreadMsg(final SimpleCallBack<List<MessageBean>> callBack) {
        EasyHttp.post(ApiManager.URL_GETUNREADMSG)
                .execute(new SimpleCallBack<List<MessageBean>>() {
                    @Override
                    public void onError(ApiException e) {
                        callBack.onError(e);
                    }

                    @Override
                    public void onSuccess(List<MessageBean> result) {
                        callBack.onSuccess(result);
                    }
                });
    }

    @Override
    public void getMsgList(int type, final SimpleCallBack<List<MessageBean>> callBack) {
        EasyHttp.post(ApiManager.URL_GETMSGLIST)
                .params("type", type + "")
                .execute(new SimpleCallBack<List<MessageBean>>() {
                    @Override
                    public void onError(ApiException e) {
                        callBack.onError(e);
                    }

                    @Override
                    public void onSuccess(List<MessageBean> result) {
                        callBack.onSuccess(result);
                    }
                });
    }
}
